﻿using System;
using MyHealthByDesign.Domain;

namespace MyHealthByDesign.Admin
{
    /// <summary>
    /// Description:
    /// Admin Master page for website page based on site Master page
    /// 
    /// Author: Mark Servais
    /// Date Created: 11/30/2011
    /// 
    /// Other code files referenced:
    /// None.
    /// 
    /// Regression Test Information:
    /// None.
    /// 
    /// Revision History:
    /// None.
    /// 
    /// Known Faults:
    /// None.
    /// </summary>
    public partial class Admin : System.Web.UI.MasterPage
    {
        /// <summary>
        /// Page Load event handler - retrieve user from session
        /// 
        /// PreConditions:
        /// None
        /// 
        /// PostConditions:
        /// Page displayed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["Admin"] != null)
            {
                User user = (User)Session["Admin"];
                lblUser.Text = user.Firstname;
                lnkLogout.Text = "[LogOut]";
            }
            else
            {
                lblUser.Text = string.Empty;
                Response.Redirect("default.aspx");
            }
        }

        /// <summary>
        /// logout button event handler - set user session to null and redirect to default page
        /// 
        /// PreConditions:
        /// None
        /// 
        /// PostConditions:
        /// Page redirected
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lnkLogout_Click(object sender, EventArgs e)
        {
            Session["Admin"] = null;
            Response.Redirect("default.aspx");
        }
    }
}